select '01. Liczba pacjentów zarejestrowanych w systemie E-pacjent' as OPIS_STATUSU, count(*) as liczba from HIPADM.HIP_PATIENTS union all select '01. -- a) z aktywnymi kontami użytkownika ' , count(*) as liczba from HIPADM.HIP_PATIENTS where state in ('A','M') union all select '01. -- b) nieaktywne konta użytkownika ' , count(*) as liczba from HIPADM.HIP_PATIENTS where state in ('R','D','C'); select '01 wykonanych terminów' as Status, to_char(planned_time,'YYYY') as rok , count(*) as liczba from hipadm.hip_bookings where state='D' and to_char(planned_time,'YYYY') ='2014' group by to_char(planned_time,'YYYY') union all select '02 potwierdzonych przez infomedica' , to_char(planned_time,'YYYY') as rok , count(*) as liczba from hipadm.hip_bookings where state='A' and to_char(planned_time,'YYYY') ='2014' group by to_char(planned_time,'YYYY') union all select '04 anulowanych' , to_char(planned_time,'YYYY') as rok , count(*) as liczba from hipadm.hip_bookings where state='C' and to_char(planned_time,'YYYY') ='2014' group by to_char(planned_time,'YYYY') union all select '03 potwierdzonych przez pacjenta' , to_char(planned_time,'YYYY') as rok , count(*) as liczba from hipadm.hip_bookings where state='F' and to_char(planned_time,'YYYY') ='2014' group by to_char(planned_time,'YYYY') order by 1;